package setting

import (
	"github.com/spf13/viper"
)

func init() {
	viper.SetConfigName("conf")
	viper.SetConfigFile("config.yaml")

}

type Setting struct {
	DataPath string
	Port     int
}

var GlobalSetting = &Setting{}

func ReadGlobalSetting() (*Setting, error) {

	if err := viper.ReadInConfig(); err != nil {
		return nil, err
	}

	GlobalSetting.DataPath = viper.GetString("dataPath")
	GlobalSetting.Port = viper.GetInt("Port")
	return GlobalSetting, nil
}
